using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace CodePlex.SpaceBlock.UI.Controls
{
    public abstract class 
        BaseView<TControl> : IView
        where TControl : Control, new()
    {


        protected abstract void InitializeControl(TControl control);

        private readonly string _caption;
        private readonly string _imageHint;
        private readonly Keys _shortcutKeys;
        private readonly string _tooltip;

        private TControl _control;

        protected BaseView(string caption, string imageHint, Keys shortcutKeys, string tooltip)
        {
            _caption = caption;
            _imageHint = imageHint;
            _shortcutKeys = shortcutKeys;
            _tooltip = tooltip;
        }

        public string Caption
        {
            get
            {
                return _caption;
            }
        }

        public string ImageHint
        {
            get
            {
                return _imageHint;
            }
        }

        public Keys ShortcutKeys
        {
            get
            {
                return _shortcutKeys;
            }
        }

        public string Tooltip
        {
            get
            {
                return _tooltip;
            }
        }

        

       

        public Control Control
        {
            get 
            { 
                if (_control == null) 
                {
                    _control = new TControl();
                }
                return _control;

            }
        }

        public void Initialize()
        {
            this.InitializeControl(this.ControlStrong);
        }

        public TControl ControlStrong
        {
            get 
            {
                return this.Control as TControl;
            }
        }

      
    }
}
